# 特征抽取

## 导入包
from sklearn.feature_extraction.text import CountVectorizer

# 实例化 CountVectorizer
vector = CountVectorizer()

# 调用fit_transform输入并转换数据
res = vector.fit_transform(["life is short","life is long"])

# 打印结果
print(vector.get_feature_names()) #['is', 'life', 'long', 'short']
#[[1 1 0 1]
# [1 1 1 0]]
print(res.toarray())